package com.shiwaixiangcun.customer.helper;

import android.content.Context;
import android.content.pm.PackageManager;
import android.util.Log;

/**
 * Author   Administrator
 * Date     2018/2/23
 * Desc     更新
 *
 * @author Administrator
 */

public class UpdateHelper {
    private static final UpdateHelper ourInstance = new UpdateHelper();
    public static boolean needFitAndroidN = true;
    public static boolean showNotification = true;
    private static String DEBUG_TAG = "updateHelper";
    private static Context mContext;
    private UpdateHelper() {

    }

    public static void needFitAndroidN(boolean needFitAndroidN) {
        UpdateHelper.needFitAndroidN = needFitAndroidN;
    }

    public static UpdateHelper getInstance() {
        return ourInstance;
    }


    public String getVersionName(Context context) {

        String verName = "";
        try {
            verName = context.getPackageManager().getPackageInfo(
                    "com.shiwaixiangcun.customer", 0).versionName;
        } catch (PackageManager.NameNotFoundException e) {
            Log.e(DEBUG_TAG, "获取versionName出错");
        }
        return verName;
    }

    /**
     * 获取版本 Code
     */
    public int getVersionCode(Context context) {
        int versionCode = -1;
        try {
            versionCode = context.getPackageManager().getPackageInfo(
                    "com.shiwaixiangcun.customer", 0).versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            Log.e(DEBUG_TAG, "获取版本Code出错");
        }
        return versionCode;
    }
}
